package com.bmslz.monitor.base.dto;

import com.bmslz.monitor.base.util.StringUtils;
import com.bmslz.monitor.base.config.excep.MyException;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @Description: 用户注册/修改入参
 * @Author: bobo
 * @Date: 2025-08-23
 * @Version: V1.0
 */
@Data
public class UserSaveDto {
    @ApiModelProperty(value = "用户ID")
    private String id;//用户ID
    @ApiModelProperty(value = "用户名")
    private String username;//用户名
    @ApiModelProperty(value = "密码")
    private String password;//密码
    @ApiModelProperty(value = "角色")
    private String role;//角色
    @ApiModelProperty(value = "真实姓名")
    private String name;//真实姓名
    @ApiModelProperty(value = "真实姓名")
    /**套餐结束时间*/
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date orderCloseTime;//套餐结束时间

    public void check() {
        if (StringUtils.isEmpty(username)) {
            throw new MyException(500, "用户名不能为空");
        }
        if (StringUtils.isEmpty(role)) {
            throw new MyException(500, "角色不能为空");
        }
        if (StringUtils.isEmpty(name)) {
            throw new MyException(500, "真实姓名不能为空");
        }
    }
}
